/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.treepoke.util.base;

import com.treepoke.util.dto.AuditoriaDTO;
import com.treepoke.util.logging.CRCCLogger;
import com.treepoke.util.properties.TPConstant;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 *
 * @author wklinger
 */
public class TPBaseEntity implements Serializable {

    private CRCCLogger logger = CRCCLogger.getLogger(TPConstant.getNOMBRE_APLICACION());
    private AuditoriaDTO auditoriaDTO;

    @Override
    public String toString() {
        Method[] methods = this.getClass().getMethods();
        StringBuilder sb = new StringBuilder();
        for (Method method : methods) {
            try {
                if (method.getName().startsWith("get")) {
                    Object o = method.invoke(this, (Object[]) null);
                    sb.append(method.getName()).append(": ").append((o != null)? o.toString() : "").
                            append(System.getProperty("line.separator"));
                }
            } catch (InvocationTargetException ex) {
                logger.errorMessage(ex.getMessage(), ex);
            } catch (Exception ex) {
                logger.errorMessage(ex.getMessage(), ex);
            }
        }
        return sb.toString();
    }
    
    public AuditoriaDTO getAuditoriaDTO() {
        return auditoriaDTO;
    }

    public void setAuditoriaDTO(AuditoriaDTO auditoriaDTO) {
        this.auditoriaDTO = auditoriaDTO;
    }
}
